Skip to content

[BUGFIX] TimeSeriesChart: match byName overrides exactly in the migration - #954

Merged
Gladorme merged 1 commit into
perses:mainfrom
mohitmishra786:4786-timeserieschart-byname
Nov 26, 2026
Merged

Gladorme merged 1 commit into
perses:mainfrom
mohitmishra786:4786-timeserieschart-byname

Conversation

@mohitmishra786

Copy link
Copy Markdown
Contributor

Description

Fixes perses/perses#4786

The regexp match added for byRegexp overrides in #334 also applied to byName, so a byName option was used as an unanchored regexp. In the migration:

  • 5m also matched the target 15m; with a second override for 15m, the two colors conflicted and the migration failed (spec.#querySettings.1.colorValue: 2 errors in empty disjunction);
  • a byName option that is not a valid regexp, such as rate(5m, failed with invalid regexp;
  • a target without legendFormat failed with cannot use null (type null) as type string in =~.

byName now compares the legendFormat exactly. The regexp is only evaluated for byRegexp on a target with a legendFormat. This is done with comprehension guards rather than &&: an error in any operand of && or || fails the expression, so legendFormat != null && legendFormat =~ ... still fails (I tried it).

New tests:

  • override-byname-exact-match: byName overrides for 5m, 15m and rate(5m; each target gets only its own color.
  • override-without-legendformat: byName and byRegexp overrides on a target without legendFormat; no query setting.

Both fail without the change and pass with it. percli plugin test-schemas --plugin.path=timeserieschart passes (20 tests) with percli v0.55.1, the version used by CI, and cue fmt v0.17.1 doesn't change the file.

I also ran the fixed script in a Perses server (main, TimeSeriesChart 0.15.0-beta.1): the three reproducers of the issue and the dashboard 8919 from grafana.com now migrate (HTTP 200) instead of returning a 400, and its panel 系统平均负载 gets the four expected colors (three from byName, one from byRegexp).

byRegexp patterns that RE2 doesn't support, such as lookaheads, still fail the migration, as before; that is left out of this change.

Screenshots

N/A

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the
    following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

UI Changes

  • Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • Code follows the UI guidelines.

…tion

The regexp match added for byRegexp overrides also applied to byName, so a
byName option was used as an unanchored regexp: "5m" also matched "15m",
which failed the migration when "15m" had its own color, and a name that is
not a valid regexp failed it too. A target without legendFormat failed on
null =~ string.

byName now compares the legendFormat exactly. The regexp is only evaluated
for byRegexp overrides on a target with a legendFormat, behind comprehension
guards, since an error in any operand of && or || fails the expression.

Fixes perses/perses#4786

Signed-off-by: Mohit Mishra <immadmohit@gmail.com>
@mohitmishra786

Copy link
Copy Markdown
Contributor Author

@jgbernalp could you please review this, whenever you get some time?
thanks in advance

@Gladorme Gladorme left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks :)

@Gladorme
Gladorme added this pull request to the merge queue Nov 26, 2026
Merged via the queue into perses:main with commit be75312 Nov 26, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Grafana migration: TimeSeriesChart byName overrides are matched as a regexp

2 participants